Skip to content

Fix tail -c OOM on large byte counts via stdin#24

Closed
kelp wants to merge 1 commit into
mainfrom
fix-tail-large-c-oom
Closed

Fix tail -c OOM on large byte counts via stdin#24
kelp wants to merge 1 commit into
mainfrom
fix-tail-large-c-oom

Conversation

@kelp

@kelp kelp commented Mar 31, 2026

Copy link
Copy Markdown
Owner

Summary

  • tail -c 10000000000 via stdin (pipes, /dev/null) caused OOM because processInputByBytesNoSeek pre-allocated the full byte_count as a circular buffer
  • Cap the circular buffer at 64MB; for larger requests, fall back to a dynamic ArrayList that grows only with actual input data
  • Fixes audit finding F64: all 87 tail integration tests now pass

Test plan

  • zig build test --summary all -- all 1984 unit tests pass
  • just it-util tail -- all 87 integration tests pass (0 failures)

processInputByBytesNoSeek pre-allocated byte_count bytes
unconditionally, causing OOM for values like 10GB even on
empty input. Cap the circular buffer at 64MB and fall back
to a dynamic list that grows only with actual input data.
@kelp

kelp commented May 27, 2026

Copy link
Copy Markdown
Owner Author

Already merged. The 64MB MAX_CIRCULAR_BUFFER cap and processInputByBytesNoSeekDynamic fallback are on main, rewritten for 0.16 readers.

@kelp kelp closed this May 27, 2026
@kelp kelp deleted the fix-tail-large-c-oom branch May 27, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant